Skip to content

docs: refactor README, offload API docs, and implement unique Cyber N… - #35

Merged
yash-pouranik merged 8 commits into
mainfrom
docs/refactor-readme
Mar 4, 2026
Merged

docs: refactor README, offload API docs, and implement unique Cyber N…#35
yash-pouranik merged 8 commits into
mainfrom
docs/refactor-readme

Conversation

@yash-pouranik

@yash-pouranik yash-pouranik commented Mar 4, 2026

Copy link
Copy Markdown
Member

PR Description: Documentation Refresh & Unique Branding Identity 🟢🚀

📝 Overview

This PR introduces a comprehensive overhaul of the project's documentation and visual identity. We've moved away from generic templates to establish a unique, professional "Cyber Node" brand for urBackend, while also cleaning up the codebase for better maintainability.

✨ Key Changes

💎 Unique Visual Identity

  • Cyber Node Branding: Implemented a custom-designed visual identity featured around the "Abstract B" (Cyber Node) motif.
  • New Assets: Added high-quality logo.png and a simplified, minimalist banner.png to the project root.
  • Consistent Theme: Unified the project under a premium Neon Green on Black aesthetic.

📖 Documentation Overhaul

  • README Refresh: Completely redesigned README.md to be a high-impact, product-focused landing page (What, Why, USPs).
  • API Guidance Offloaded: Moved all technical implementation details and code examples to a new dedicated file: API_USAGE.md.
  • Terminal Aesthetics: Integrated >_ terminal-inspired iconography throughout the documentation for a true developer-tool feel.

🛠️ Codebase Cleanup & Refactoring

  • AI Comment Stripping: Performed a full scan and removal of verbose AI-generated comments across all backend controllers and frontend components.
  • Functional Documentation: Replaced verbose notes with concise, functional markers (e.g., // POST FOR - SOMETHING).
  • Middleware Streamlining: Cleaned up verifyApiKey.js and app.js, removing leftover debugging logs and performance tracking.

🚀 Verification Results

  • Assets Verified: Banner and logo are correctly rendered in README.md.
  • Links Verified: All navigation links and cross-references (Docs, Discord, Dashboard) are functional.
  • Code Standard: Codebase is clean, minimalist, and free of redundant AI verbosity.

Created with ❤️ for the urBackend Community.

Summary by CodeRabbit

  • Documentation
    • Added a comprehensive "urBackend API Usage Guide" with endpoint examples, auth flows, database/storage operations, and security guidance.
    • Redesigned README with a branded header, streamlined feature highlights, and simplified quick-start links.
  • Bug Fixes
    • Release creation now enforces authorization.
    • Improved origin/domain validation and wildcard handling for API access.
  • Features
    • Project settings: cleaner domain input handling and explicit wildcard behavior for allowed domains.

@vercel

vercel Bot commented Mar 4, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
ur-backend Ready Ready Preview, Comment Mar 4, 2026 7:22pm

@coderabbitai

coderabbitai Bot commented Mar 4, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Adds a new API usage guide (API_USAGE.md), rewrites README.md into a branded, concise landing page, and updates backend release endpoints: minor comment changes, controller now selects full Developer docs (lean query) for email construction, and the POST /releases route now includes an authorization middleware before createRelease. Also tightens origin validation in API key middleware and normalizes allowed-domain handling in frontend ProjectSettings.

Changes

Cohort / File(s) Summary
API Documentation
API_USAGE.md
New comprehensive API usage guide with endpoints, auth flows, database & storage examples, headers, and security guidance.
Repository Landing
README.md
Replaced detailed tutorial-style README with a branded, concise landing page, trimmed examples, and reorganized sections.
Backend: Releases
backend/controllers/release.controller.js, backend/routes/releases.js
Controller changed to use a lean fetch of Developer documents (not projection-only) when building email list; POST / route now inserts authorization middleware before createRelease. Minor comment text edits.
Backend: API Key Middleware
backend/middleware/verifyApiKey.js
Reworked Origin parsing and hostname-aware domain checks; supports wildcard (*.domain) matching against hostnames and trims trailing slashes from allowed domains.
Frontend: Project Settings
frontend/src/pages/ProjectSettings.jsx
Normalize domain input: trim whitespace, strip trailing slash (unless "*"), enforce "*" as exclusive entry, and remove "*" when adding specific domains.

Sequence Diagram(s)

mermaid
sequenceDiagram
participant Client as Client
participant Router as Releases Route
participant Auth as Authorization Middleware
participant Ctrl as createRelease Controller
participant Queue as EmailQueue

Client->>Router: POST /api/releases (payload)
Router->>Auth: validate token / permissions
Auth-->>Router: allow / deny
Router->>Ctrl: call createRelease
Ctrl->>Queue: enqueue notification emails (using Developer docs)
Ctrl-->>Client: respond (201 / error)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • Feat/api security updates #34 — Related feature PR touching releases routes/controllers and origin/allowed-domain handling; likely overlaps changes to authorization and domain checks.

Poem

🐰 I hopped through docs and tamed the trace,
Routes now check before they embrace.
Domains trimmed, wildcards held tight,
Emails queued by moonlit night.
I nibble code and hop with delight. 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title is truncated and incomplete, ending with 'unique Cyber N…', which obscures the full intent and makes it difficult to understand the complete scope of changes. Complete the pull request title to clearly convey all major changes. Consider: 'docs: refactor README, offload API docs, and implement Cyber Node branding' or similar concise, complete phrasing.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch docs/refactor-readme

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the project's external presentation and internal maintainability. The primary goal was to establish a distinct brand identity for urBackend, making it more appealing and professional, while simultaneously streamlining the documentation and cleaning up the codebase for improved clarity and efficiency. The changes aim to provide a better first impression for new users and a cleaner development experience for contributors.

Highlights

  • Unique Visual Identity: Implemented a custom 'Cyber Node' branding with a new logo.png and banner.png, establishing a consistent Neon Green on Black aesthetic across the project documentation.
  • Documentation Overhaul: Completely redesigned the README.md to be a high-impact, product-focused landing page. All technical API implementation details and code examples were offloaded to a new dedicated file, API_USAGE.md.
  • Codebase Cleanup & Refactoring: Performed a full scan and removal of verbose AI-generated comments across backend controllers and frontend components. Replaced these with concise, functional markers (e.g., // POST FOR - SOMETHING). Middleware files like verifyApiKey.js and app.js were also cleaned of leftover debugging logs and performance tracking.
Changelog
  • API_USAGE.md
    • Added a new dedicated guide for API usage, including authentication, database, and storage API examples.
  • README.md
    • Completely redesigned the README to focus on product overview and unique branding.
    • Removed detailed API usage instructions, offloading them to API_USAGE.md.
    • Integrated new banner.png and logo.png for a consistent 'Cyber Node' visual identity.
    • Updated feature list with terminal-inspired iconography and new feature descriptions.
    • Replaced the tech stack section with a more structured 'Infrastructure' table.
    • Removed sections on limits, quotas, and roadmap.
  • backend/controllers/release.controller.js
    • Updated comments for getAllReleases and createRelease functions for conciseness.
    • Removed verbose AI-generated comments related to email queuing logic.
  • backend/routes/releases.js
    • Modified route comments to adopt a more concise, functional documentation style.
Activity
  • The pull request was opened by yash-pouranik.
  • No additional human activity (comments, reviews) has been recorded yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
backend/controllers/release.controller.js (2)

2-2: 🛠️ Refactor suggestion | 🟠 Major

Unused import: Developer model.

The Developer model is imported but never used. If email notifications are being removed (Option B above), this import should also be removed along with the emailQueue import on line 3.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@backend/controllers/release.controller.js` at line 2, Remove the unused
Developer import (require("../models/Developer")) and the related emailQueue
import (the require on line 3) from release.controller.js since email
notifications were removed; update any leftover references to Developer or
emailQueue in functions like the release creation/notification handlers if
present, and run lint/tests to ensure no unused-vars remain.

39-47: ⚠️ Potential issue | 🔴 Critical

Critical: developers is undefined — this will crash at runtime.

The variable developers is referenced but never defined in this function. Based on the AI summary and the relevant code snippets, the code that fetched verified developers from the database was removed, but the email queuing logic that depends on it remains.

This will throw ReferenceError: developers is not defined when an admin attempts to create a release.

Either restore the developer fetch or remove the email queuing logic entirely:

Option A: Restore developer fetch (if email notifications are intended)
         return res.status(400).json({ error: "Missing version, title, or content" });
         }
 
+        const developers = await Developer.find({ isVerified: true });
+
         const newRelease = new Release({ 
             version, 
             title, 
Option B: Remove email queuing (if notifications are no longer needed)
         await newRelease.save();
 
-        const emails = developers.map(dev => dev.email);
-        await Promise.all(emails.map(email => 
-            emailQueue.add('release-email', {
-                email,
-                version,
-                title,
-                content
-            })
-        ));
-
-        res.status(201).json({ 
-            message: "Release published! Emails queued.", 
-            count: emails.length 
-        });
+        res.status(201).json({ 
+            message: "Release published!", 
+            release: newRelease 
+        });
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@backend/controllers/release.controller.js` around lines 39 - 47, The code
references developers when building emails for queuing (const emails =
developers.map(...)) but developers is not defined; either restore the DB fetch
that populates developers (e.g., reintroduce the query that finds verified
developers/users and assigns to developers before mapping) or remove the
email-queuing block entirely; locate the email queuing logic in the release
creation handler (the section using const emails = developers.map(...) and
emailQueue.add('release-email', ...)) and either (A) add back the developer
lookup (ensure it retrieves verified developers and handles empty
results/errors) before mapping, or (B) delete the mapping and emailQueue.add
calls so the release flow no longer depends on a nonexistent developers
variable.
🧹 Nitpick comments (1)
API_USAGE.md (1)

7-9: Add language specifier to fenced code block.

The base URL code block is missing a language identifier, which triggers a markdown lint warning. Adding text or plaintext would satisfy the linter and improve rendering consistency.

📝 Proposed fix
-```
+```text
 https://api.urbackend.bitbros.in
</details>

<details>
<summary>🤖 Prompt for AI Agents</summary>

Verify each finding against the current code and only fix it if needed.

In @API_USAGE.md around lines 7 - 9, The fenced code block showing the base URL
is missing a language specifier which triggers a markdown lint warning; update
the block around the URL https://api.urbackend.bitbros.in in API_USAGE.md to
include a language tag such as text or plaintext (e.g., change the opening
triple backticks to ```text) so the linter stops flagging it and rendering is
consistent.


</details>

</blockquote></details>

</blockquote></details>

<details>
<summary>🤖 Prompt for all review comments with AI agents</summary>

Verify each finding against the current code and only fix it if needed.

Inline comments:
In @README.md:

  • Around line 87-89: The contributor image tag in README.md is missing alt text,
    harming accessibility; update the element inside the anchor (the
    contributors badge block) to include a meaningful alt attribute (e.g.,
    alt="Contributors to the repository") so screen readers can describe the image;
    locate the ...... snippet
    and add the alt attribute to the element.

Outside diff comments:
In @backend/controllers/release.controller.js:

  • Line 2: Remove the unused Developer import (require("../models/Developer"))
    and the related emailQueue import (the require on line 3) from
    release.controller.js since email notifications were removed; update any
    leftover references to Developer or emailQueue in functions like the release
    creation/notification handlers if present, and run lint/tests to ensure no
    unused-vars remain.
  • Around line 39-47: The code references developers when building emails for
    queuing (const emails = developers.map(...)) but developers is not defined;
    either restore the DB fetch that populates developers (e.g., reintroduce the
    query that finds verified developers/users and assigns to developers before
    mapping) or remove the email-queuing block entirely; locate the email queuing
    logic in the release creation handler (the section using const emails =
    developers.map(...) and emailQueue.add('release-email', ...)) and either (A) add
    back the developer lookup (ensure it retrieves verified developers and handles
    empty results/errors) before mapping, or (B) delete the mapping and
    emailQueue.add calls so the release flow no longer depends on a nonexistent
    developers variable.

Nitpick comments:
In @API_USAGE.md:

  • Around line 7-9: The fenced code block showing the base URL is missing a
    language specifier which triggers a markdown lint warning; update the block
    around the URL https://api.urbackend.bitbros.in in API_USAGE.md to include a
    language tag such as text or plaintext (e.g., change the opening triple
    backticks to ```text) so the linter stops flagging it and rendering is
    consistent.

</details>

---

<details>
<summary>ℹ️ Review info</summary>

<details>
<summary>⚙️ Run configuration</summary>

**Configuration used**: Organization UI

**Review profile**: CHILL

**Plan**: Pro

**Run ID**: `4dcf784a-f1f2-4f71-8b78-7ffe60fb31dd`

</details>

<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between 227c512844e1963e12b16ad04a891370389917eb and 4cbc1de84af08bbd6f13eb4ef828f15462097da9.

</details>

<details>
<summary>⛔ Files ignored due to path filters (3)</summary>

* `banner.png` is excluded by `!**/*.png`
* `frontend/public/logo.png` is excluded by `!**/*.png`
* `logo.png` is excluded by `!**/*.png`

</details>

<details>
<summary>📒 Files selected for processing (4)</summary>

* `API_USAGE.md`
* `README.md`
* `backend/controllers/release.controller.js`
* `backend/routes/releases.js`

</details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->

Comment thread README.md

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the project's documentation, establishing a 'Cyber Node' brand, moving API usage details to API_USAGE.md, refreshing README.md, and removing verbose AI-generated comments from backend controllers. However, it introduces significant regressions in release management functionality, specifically omitting authentication middleware from the release creation route and removing critical logic for fetching developer emails from the controller. These changes lead to a broken endpoint that will crash with a 500 error and fail to enforce access control. Additionally, a ReferenceError will occur in release.controller.js due to a removed variable for email queuing, and the API_USAGE.md could be more explicit about public vs. secret API key usage for improved security practices.

Comment thread backend/routes/releases.js Outdated
Comment thread API_USAGE.md
```javascript
// Replace :collectionName with your actual collection name (e.g., 'products')
const res = await fetch('https://api.urbackend.bitbros.in/api/data/products', {
headers: { 'x-api-key': 'YOUR_API_KEY' }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The example for 'Get All Items' uses YOUR_API_KEY. Given the 'Security Best Practices' section, it would be clearer and reinforce best practices to explicitly use YOUR_PUBLIC_API_KEY here, as this is typically a read-only operation suitable for frontend requests.

Suggested change
headers: { 'x-api-key': 'YOUR_API_KEY' }
headers: { 'x-api-key': 'YOUR_PUBLIC_API_KEY' }

Comment thread API_USAGE.md
method: 'POST',
headers: {
'Content-Type': 'application/json',
'x-api-key': 'YOUR_API_KEY'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

For sensitive operations like 'Sign Up User', it's crucial to use the Secret API Key as per the 'Security Best Practices'. The current YOUR_API_KEY placeholder might lead developers to use a public key in an insecure context. Please update this example to explicitly use YOUR_SECRET_API_KEY or add a comment to clarify its usage.

Suggested change
'x-api-key': 'YOUR_API_KEY'
'x-api-key': 'YOUR_SECRET_API_KEY'


// 1. Fetch all verified developers
const developers = await Developer.find({ isVerified: true }, 'email');
const emails = developers.map(dev => dev.email);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security-medium medium

The createRelease function attempts to map over a developers variable on this line, but the code to fetch these developers was removed. This will cause a ReferenceError at runtime, leading to a Denial of Service for the release creation and email notification functionality.

        const developers = await Developer.find({ isVerified: true }, 'email');
        const emails = developers.map(dev => dev.email);

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@backend/controllers/release.controller.js`:
- Around line 38-39: The Developer.find call is loading full documents
(including sensitive fields) though only email is used; change the query to
project only the email field (e.g., use Developer.find({ isVerified: true },
'email') or .select('email') / .select('email -_id')) so only emails are
returned, then map those results to build emails; update the symbols
Developer.find, developers and emails accordingly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 86b3284c-5024-4885-9567-357d8dd003c4

📥 Commits

Reviewing files that changed from the base of the PR and between 4cbc1de and dfd6913.

📒 Files selected for processing (1)
  • backend/controllers/release.controller.js

Comment thread backend/controllers/release.controller.js Outdated
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Comment thread backend/routes/releases.js Fixed
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@yash-pouranik
yash-pouranik temporarily deployed to docs/refactor-readme - urBackend-frankfrut PR #35 March 4, 2026 19:22 — with Render Destroyed

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
backend/middleware/verifyApiKey.js (1)

59-84: ⚠️ Potential issue | 🟡 Minor

Normalize allowedDomains before the wildcard short-circuit.

Line 62 checks allowedDomains.includes('*') on raw values, but Line 73-Line 76 normalize entries later. With denormalized stored values, wildcard behavior can diverge from match behavior.

Proposed patch
-        if (!isSecret) {
-            let allowedDomains = project.allowedDomains || ['*'];
+        if (!isSecret) {
+            const normalizeDomain = (d) => String(d).trim().replace(/\/+$/, '');
+            let allowedDomains = (project.allowedDomains || ['*'])
+                .map(normalizeDomain)
+                .filter(Boolean);
             const origin = req.headers.origin || req.headers.referer;

             if (!allowedDomains.includes('*')) {
                 if (!origin) {
                     return res.status(403).json({ error: "Forbidden: Origin header missing and this key is restricted to specific domains." });
                 }

                 try {
                     const parsedOrigin = new URL(origin);
                     const originUrl = parsedOrigin.origin; 
                     const originHostname = parsedOrigin.hostname;

                     const isAllowed = allowedDomains.some(domain => {
-                        let cleanDomain = domain.trim();
-                        if (cleanDomain.endsWith('/')) {
-                            cleanDomain = cleanDomain.slice(0, -1);
-                        }
+                        const cleanDomain = domain;

                         if (cleanDomain.startsWith('*.')) {
                             const baseDomain = cleanDomain.substring(2);
                             return originHostname === baseDomain || originHostname.endsWith('.' + baseDomain);
                         }

                         return originUrl === cleanDomain || originHostname === cleanDomain;
                     });
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@backend/middleware/verifyApiKey.js` around lines 59 - 84, Normalize the
allowedDomains array before the wildcard short-circuit: transform
project.allowedDomains into a cleaned array (trim entries and remove trailing
slashes) assigned to allowedDomains, then check allowedDomains.includes('*') and
proceed; keep the existing matching logic that uses allowedDomains.some(...)
(referencing allowedDomains, origin, parsedOrigin, originUrl, originHostname,
and the isAllowed calculation) so wildcard checks and later per-entry matching
behave consistently for denormalized stored values.
♻️ Duplicate comments (1)
README.md (1)

80-82: ⚠️ Potential issue | 🟡 Minor

Add alt text to contributor image for accessibility.

The contributors image is missing alternate text, which impacts accessibility for screen reader users.

📝 Proposed fix
 <a href="https://github.com/yash-pouranik/urbackend/graphs/contributors">
-  <img src="https://contrib.rocks/image?repo=yash-pouranik/urbackend" />
+  <img src="https://contrib.rocks/image?repo=yash-pouranik/urbackend" alt="Contributors to urBackend" />
 </a>
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@README.md` around lines 80 - 82, The contributors image (<img
src="https://contrib.rocks/image?repo=yash-pouranik/urbackend" />) lacks an alt
attribute; update the <img> tag in the README to include descriptive alt text
(for example: alt="Contributors to yash-pouranik/urbackend") so screen readers
can convey the image purpose while keeping the existing link and src intact.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@frontend/src/pages/ProjectSettings.jsx`:
- Around line 927-947: Normalize existing stored entries before duplicate
checks: create a normalized copy of the domains array (e.g., normalizedDomains)
using the same rules applied to newDomain (trim and remove trailing slash unless
value is "*") and use normalizedDomains for the includes check and for filtering
when building updated; specifically, update logic around domain, newDomain,
domains and updated so the duplicate detection and removal of "*" operate on
normalizedDomains (then push the normalized new domain) to prevent semantically
duplicate entries.

---

Outside diff comments:
In `@backend/middleware/verifyApiKey.js`:
- Around line 59-84: Normalize the allowedDomains array before the wildcard
short-circuit: transform project.allowedDomains into a cleaned array (trim
entries and remove trailing slashes) assigned to allowedDomains, then check
allowedDomains.includes('*') and proceed; keep the existing matching logic that
uses allowedDomains.some(...) (referencing allowedDomains, origin, parsedOrigin,
originUrl, originHostname, and the isAllowed calculation) so wildcard checks and
later per-entry matching behave consistently for denormalized stored values.

---

Duplicate comments:
In `@README.md`:
- Around line 80-82: The contributors image (<img
src="https://contrib.rocks/image?repo=yash-pouranik/urbackend" />) lacks an alt
attribute; update the <img> tag in the README to include descriptive alt text
(for example: alt="Contributors to yash-pouranik/urbackend") so screen readers
can convey the image purpose while keeping the existing link and src intact.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 94cd234d-343f-48f7-abef-ad7e64c58501

📥 Commits

Reviewing files that changed from the base of the PR and between d3ed1a8 and 2943ceb.

📒 Files selected for processing (3)
  • README.md
  • backend/middleware/verifyApiKey.js
  • frontend/src/pages/ProjectSettings.jsx

Comment on lines +927 to +947
let domain = newDomain.trim();
if (!domain) return;

// basic validation
// basic cleanup
if (domain !== "*" && domain.endsWith("/")) {
domain = domain.slice(0, -1);
}

if (domains.includes(domain)) {
return toast.error("Domain already added");
}

const updated = [...domains, domain];
let updated;
if (domain === "*") {
// If user adds '*', it overrides everything else
updated = ["*"];
} else {
// If user adds a specific domain, ensure '*' is removed
updated = domains.filter((d) => d !== "*");
updated.push(domain);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Normalize existing domains before duplicate detection.

Line 935 compares against raw domains, while Line 927-Line 933 normalizes only the new input. If stored entries contain slash variants (possible via backend/controllers/project.controller.js Line 711-Line 738), semantically duplicate domains can be added.

Proposed patch
   const addDomain = () => {
-    let domain = newDomain.trim();
+    const normalizeDomain = (value) => {
+      let d = value.trim();
+      if (d !== "*") d = d.replace(/\/+$/, "");
+      return d;
+    };
+
+    let domain = normalizeDomain(newDomain);
     if (!domain) return;
-    
-    // basic cleanup
-    if (domain !== "*" && domain.endsWith("/")) {
-      domain = domain.slice(0, -1);
-    }
-
-    if (domains.includes(domain)) {
+
+    const normalizedExisting = domains.map(normalizeDomain);
+    if (normalizedExisting.includes(domain)) {
       return toast.error("Domain already added");
     }

     let updated;
     if (domain === "*") {
       // If user adds '*', it overrides everything else
       updated = ["*"];
     } else {
       // If user adds a specific domain, ensure '*' is removed
-      updated = domains.filter((d) => d !== "*");
+      updated = normalizedExisting.filter((d) => d !== "*" && d !== domain);
       updated.push(domain);
     }

     handleUpdate(updated);
     setNewDomain("");
   };
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
let domain = newDomain.trim();
if (!domain) return;
// basic validation
// basic cleanup
if (domain !== "*" && domain.endsWith("/")) {
domain = domain.slice(0, -1);
}
if (domains.includes(domain)) {
return toast.error("Domain already added");
}
const updated = [...domains, domain];
let updated;
if (domain === "*") {
// If user adds '*', it overrides everything else
updated = ["*"];
} else {
// If user adds a specific domain, ensure '*' is removed
updated = domains.filter((d) => d !== "*");
updated.push(domain);
}
const normalizeDomain = (value) => {
let d = value.trim();
if (d !== "*") d = d.replace(/\/+$/, "");
return d;
};
let domain = normalizeDomain(newDomain);
if (!domain) return;
const normalizedExisting = domains.map(normalizeDomain);
if (normalizedExisting.includes(domain)) {
return toast.error("Domain already added");
}
let updated;
if (domain === "*") {
// If user adds '*', it overrides everything else
updated = ["*"];
} else {
// If user adds a specific domain, ensure '*' is removed
updated = normalizedExisting.filter((d) => d !== "*" && d !== domain);
updated.push(domain);
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@frontend/src/pages/ProjectSettings.jsx` around lines 927 - 947, Normalize
existing stored entries before duplicate checks: create a normalized copy of the
domains array (e.g., normalizedDomains) using the same rules applied to
newDomain (trim and remove trailing slash unless value is "*") and use
normalizedDomains for the includes check and for filtering when building
updated; specifically, update logic around domain, newDomain, domains and
updated so the duplicate detection and removal of "*" operate on
normalizedDomains (then push the normalized new domain) to prevent semantically
duplicate entries.

@yash-pouranik
yash-pouranik merged commit 64cccab into main Mar 4, 2026
9 checks passed
@coderabbitai coderabbitai Bot mentioned this pull request Mar 6, 2026
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants